using System.Collections.Generic;
using BCW;
using UnityEngine;

public class PanelResultReward : MonoBehaviour
{
	[SerializeField]
	private GameObject bonus;

	[SerializeField]
	private UILabel title1;

	[SerializeField]
	private UILabel title2;

	[SerializeField]
	private UIGrid grid;

	[SerializeField]
	private GameObject lineAwardExample;

	[SerializeField]
	private GameObject noVipBG;

	[SerializeField]
	private GameObject vipBG;

	[SerializeField]
	private GameObject activeFrame;

	[SerializeField]
	private GameObject buttonBuyVip;

	[SerializeField]
	private GameObject labelBuyVip;

	public GameObject BonusPanel
	{
		get
		{
			return bonus;
		}
	}

	public GameObject NoVipBG
	{
		get
		{
			return noVipBG;
		}
	}

	public GameObject VipBG
	{
		get
		{
			return vipBG;
		}
	}

	public GameObject ActiveFrame
	{
		get
		{
			return activeFrame;
		}
	}

	public GameObject ButtonBuyVip
	{
		get
		{
			return buttonBuyVip;
		}
	}

	public GameObject LabelBuyVip
	{
		get
		{
			return labelBuyVip;
		}
	}

	public void SetTitle(string title)
	{
		title1.text = title;
		title2.text = title;
	}

	public void ShowRewards(List<InfoMatchReward> rewards)
	{
		foreach (InfoMatchReward reward in rewards)
		{
			GameObject gameObject = Object.Instantiate(lineAwardExample);
			gameObject.transform.SetParent(grid.transform);
			gameObject.transform.localScale = Vector3.one;
			PanelResultRewardLine component = gameObject.GetComponent<PanelResultRewardLine>();
			SetTexture(component, reward);
			component.count.text = reward.count.ToString();
			component.title.text = MatchRewardManager.GetName(reward);
			gameObject.SetActive(true);
		}
		grid.repositionNow = true;
	}

	private void SetTexture(PanelResultRewardLine rewardScript, InfoMatchReward reward)
	{
		rewardScript.texture = rewardScript.texture.ReplaceForCurrentPlatform();
		switch (reward.id)
		{
		case "gold":
			rewardScript.texture.LoadTextureAndAlphaMask("NGUI_Textures/", "gold");
			return;
		case "cash":
			rewardScript.texture.LoadTextureAndAlphaMask("NGUI_Textures/", "cash");
			return;
		case "star":
			rewardScript.texture.LoadTextureAndAlphaMask("NGUI_Textures/", "Icon_Star");
			return;
		}
		Product product = MarketController.Instance.GetProduct(reward.id);
		if (product is ProductVehicleSkin)
		{
			rewardScript.texture.LoadTextureAndAlphaMask("AtlasShopGuns/", "ASG_" + (product as ProductVehicleSkin).skinTextureName);
		}
		else if (product is ProductVehicleUpgrade || product is ProductFreeUpgrade)
		{
			rewardScript.texture.LoadTextureAndAlphaMask("AtlasShopGuns/Upgrades/", MarketController.Instance.GetProduct(reward.id).texture.Replace("Upgrades/", string.Empty));
		}
		else
		{
			rewardScript.texture.LoadTextureAndAlphaMask("AtlasShopGuns/", MarketController.Instance.GetProduct(reward.id).texture);
		}
	}
}
